## You need the following if this is ever being run as a script 
import os, sys  
  
sys.path.insert(0, "C:\Documents and Settings\wendy_admin\src\eclipse_workspace\djangodb\main")  
if not os.environ.has_key("DJANGO_SETTINGS_MODULE"):
    os.environ["DJANGO_SETTINGS_MODULE"]="wjContact.settings"
    
import datetime


from wjContact.computers.models import Computer

## Extensible Forms
import wjContact.views.forms as wjCoreForms

## Ordinary forms
from django import newforms as forms


class ComputerForm(wjCoreForms.ExtensibleForm):
#class ComputerForm(forms.Form):

    """ """   

    cbv_no = forms.CharField(max_length=4, initial='1234')
    
    
    cpu_type = forms.ChoiceField(choices = Computer.CPU_TYPES)
    cpu_speed = forms.ChoiceField(choices = Computer.CPU_SPEEDS)
    case_type = forms.ChoiceField(choices = Computer.CASE_TYPES)
    ram = forms.ChoiceField(choices = Computer.RAM_AMOUNTS)
    hard_drive_size = forms.ChoiceField(choices = Computer.HARD_DRIVE_SIZES)
    optical_device1 = forms.CharField(max_length=50, initial='CD-Rom')
    optical_device2 = forms.CharField(max_length=50, initial='CD-RW') 
    monitor_type = forms.CharField(max_length=50, initial='CRT')
    monitor_size = forms.CharField(max_length=50, initial='17')  
    modem_type = forms.CharField(max_length=50, initial='Standard')
    usb = forms.CharField(max_length=50, initial='USB2.0')
    usb_ports = forms.CharField(max_length=50, initial='2')
    distroversion = forms.CharField(max_length=50, initial='CBV Standard')  
    computer_status = forms.ChoiceField(choices = Computer.STATUS_CHOICES, 
        initial = "in_shop")
      

    def save(self):
        new_computer = Computer(
            cpu_type = self.clean_data['cpu_type'],
            cpu_speed = self.clean_data['cpu_speed'],
            case_type = self.clean_data['case_type'],
            ram = self.clean_data['ram'],
            hard_drive_size = self.clean_data['hard_drive_size'],
            optical_device1 = self.clean_data['optical_device1'],
            optical_device2 = self.clean_data['optical_device2'], 
            monitor_type = self.clean_data['monitor_type'],
            monitor_size = self.clean_data['monitor_size'],
            modem_type = self.clean_data['modem_type'],
            usb = self.clean_data['usb'],
            usb_ports = self.clean_data['usb_ports'],
            distroversion = self.clean_data['distroversion'],
            computer_status = self.clean_data['computer_status'],
            )
        new_computer.save()
        
#===============================================================================  
